import 'package:yurun_smartmerchants/models/staff_list_entity.dart';

staffListEntityFromJson(StaffListEntity data, Map<String, dynamic> json) {
	if (json['number'] != null) {
		data.number = json['number']?.toInt();
	}
	if (json['last'] != null) {
		data.last = json['last'];
	}
	if (json['size'] != null) {
		data.size = json['size']?.toInt();
	}
	if (json['totalPages'] != null) {
		data.totalPages = json['totalPages']?.toInt();
	}
	if (json['content'] != null) {
		data.content = new List<StaffListContent>();
		(json['content'] as List).forEach((v) {
			data.content.add(new StaffListContent().fromJson(v));
		});
	}
	return data;
}

Map<String, dynamic> staffListEntityToJson(StaffListEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['number'] = entity.number;
	data['last'] = entity.last;
	data['size'] = entity.size;
	data['totalPages'] = entity.totalPages;
	if (entity.content != null) {
		data['content'] =  entity.content.map((v) => v.toJson()).toList();
	}
	return data;
}

staffListContentFromJson(StaffListContent data, Map<String, dynamic> json) {
	if (json['consumerId'] != null) {
		data.consumerId = json['consumerId']?.toInt();
	}
	if (json['phone'] != null) {
		data.phone = json['phone']?.toString();
	}
	if (json['owned'] != null) {
		data.owned = json['owned'];
	}
	if (json['name'] != null) {
		data.name = json['name']?.toString();
	}
	if (json['id'] != null) {
		data.id = json['id']?.toInt();
	}
	if (json['account'] != null) {
		data.account = new StaffListContentAccount().fromJson(json['account']);
	}
	if (json['status'] != null) {
		data.status = json['status']?.toInt();
	}
	return data;
}

Map<String, dynamic> staffListContentToJson(StaffListContent entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['consumerId'] = entity.consumerId;
	data['phone'] = entity.phone;
	data['owned'] = entity.owned;
	data['name'] = entity.name;
	data['id'] = entity.id;
	if (entity.account != null) {
		data['account'] = entity.account.toJson();
	}
	data['status'] = entity.status;
	return data;
}

staffListContentAccountFromJson(StaffListContentAccount data, Map<String, dynamic> json) {
	if (json['url'] != null) {
		data.url = json['url']?.toString();
	}
	return data;
}

Map<String, dynamic> staffListContentAccountToJson(StaffListContentAccount entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['url'] = entity.url;
	return data;
}